﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bll;
using model;
using System.IO;

public partial class DeleteU : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string id = Session["userid"].ToString();
        StudentBll sbll = new StudentBll();
        ResumeBll rbll = new ResumeBll();
        EnterpriseBll ebll = new EnterpriseBll();
        ApplicationBll abll = new ApplicationBll();
        try
        {
            if (Session["usergroup"].ToString() == "student")
            {
                rbll.Delete(id);
                sbll.Delete(id);
            }
            else
            {
                abll.Delete(id);
                ebll.Delete(id);
                DirectoryInfo din = new DirectoryInfo(Server.MapPath("Pict"));
                FileInfo[] fs = din.GetFiles();
                foreach (FileInfo f in fs)
                {
                    if (Session["username"].ToString() == f.Name.Substring(0, f.Name.Length - 4))
                    {
                        f.Delete();
                    }
                }
            }
            Session["username"] = null;
            Response.Write("<script>alert('删除成功！');location.href('Default.aspx');</script>");
        }
        catch (Exception ex)
        {
            string js = "<script>alert('" + ex.Message + "');</script>";
            Response.Write(js);
        }
       
    }
}